

import {
    vec3,mat4,
} from 'gl-matrix'
import {toRadius} from "./utils";

export class Obj3d{
    position = vec3.create();
    rotation = vec3.create();
    scale = vec3.fromValues(1,1,1);

    matrix = mat4.create();

    updateMatrix(){
        mat4.identity(this.matrix);
        mat4.fromTranslation(this.matrix,this.position);
        mat4.rotateX(this.matrix,this.matrix,toRadius(this.rotation[0]));
        mat4.rotateY(this.matrix,this.matrix,toRadius(this.rotation[1]));
        mat4.rotateZ(this.matrix,this.matrix,toRadius(this.rotation[2]));
        mat4.scale(this.matrix,this.matrix,this.scale);
    }
}
